﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ShopNet.Util;

namespace ShopNet
{
    public partial class Login : System.Web.UI.Page
    {
        public new Shop Master
        {
            get
            {
                return ((Shop)(base.Master));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.ExibirMensagem(Shop.TipoMensagem.Success, string.Empty);
            RegisterHyperLink.NavigateUrl = "~/Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);

            if (Page.IsPostBack)
            {
                Page.Validate();
                if (!Page.IsValid)
                {
                    TextBox UserName = lLogin.FindControl("UserName") as TextBox;
                    TextBox Password = lLogin.FindControl("Password") as TextBox;
                    if (string.IsNullOrWhiteSpace(UserName.Text))
                    {
                        UserName.SetCssClassError();
                    }
                    if (string.IsNullOrWhiteSpace(Password.Text))
                    {
                        Password.SetCssClassError();
                    }
                }
            }
        }

        
    }
}